home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_lrm / chap04.doc < prev    next >
Text File  |  1996-01-30  |  88KB  |  1,962 lines

  1.                          4. Names and Expressions
  2.  
  3.  
  4. The rules applicable to the different forms of name and expression, and  to
  5. their evaluation, are given in this chapter.
  6.  
  7. 4.1  Names
  8.  
  9.  
  10. Names   can  denote  declared  entities,  whether  declared  explicitly  or
  11. implicitly (see 3.1).  Names can also denote objects designated  by  access
  12. values;   subcomponents  and slices of objects and values;  single entries,
  13. entry families, and entries in families of  entries.   Finally,  names  can
  14. denote attributes of any of the foregoing.
  15.  
  16.  
  17.     name ::= simple_name
  18.        | character_literal  | operator_symbol
  19.        | indexed_component  | slice
  20.        | selected_component | attribute
  21.  
  22.     simple_name ::= identifier
  23.  
  24.     prefix ::= name | function_call
  25.  
  26.  
  27. A  simple  name  for an entity is either the identifier associated with the
  28. entity by its declaration, or another identifier associated with the entity
  29. by a renaming declaration.
  30.  
  31.  
  32. Certain forms  of  name  (indexed  and  selected  components,  slices,  and
  33. attributes)  include a prefix that is either a name or a function call.  If
  34. the type of a prefix is an access type, then the prefix must not be a  name
  35. that denotes a formal parameter of mode out or a subcomponent thereof.
  36.  
  37.  
  38. If  the  prefix  of  a  name  is  a  function call, then the name denotes a
  39. component, a slice, an attribute, an entry, or an entry family,  either  of
  40. the  result  of the function call, or (if the result is an access value) of
  41. the object designated by the result.
  42.  
  43.  
  44. A prefix is said to be appropriate for a type in either  of  the  following
  45. cases:
  46.  
  47.  
  48.   -  The type of the prefix is the type considered.
  49.  
  50.  
  51.   -  The type of the prefix is an access type whose designated type is  the
  52.      type considered.
  53.  
  54.  
  55. The  evaluation  of a name determines the entity denoted by the name.  This
  56. evaluation has no other effect  for  a  name  that  is  a  simple  name,  a
  57. character literal, or an operator symbol.
  58.  
  59.  
  60. The  evaluation  of a name that has a prefix includes the evaluation of the
  61. prefix, that is, of the corresponding name or function call.  If  the  type
  62. of  the prefix is an access type, the evaluation of the prefix includes the
  63. determination of the object designated by the corresponding  access  value;
  64. the  exception  CONSTRAINT_ERROR  is raised if the value of the prefix is a
  65. null access value, except in the case of the  prefix  of  a  representation
  66. attribute (see 13.7.2).
  67.  
  68.  
  69. Examples of simple names:
  70.  
  71.     PI      --  the simple name of a number               (see 3.2.2)
  72.     LIMIT   --  the simple name of a constant             (see 3.2.1)
  73.     COUNT   --  the simple name of a scalar variable      (see 3.2.1)
  74.     BOARD   --  the simple name of an array variable      (see 3.6.1)
  75.     MATRIX  --  the simple name of a type                 (see 3.6)
  76.     RANDOM  --  the simple name of a function             (see 6.1)
  77.     ERROR   --  the simple name of an exception           (see 11.1)
  78.  
  79.  
  80. References:   access type 3.8, access value 3.8, attribute 4.1.4, belong to
  81. a  type  3.3,  character  literal  2.5,  component  3.3,   constraint_error
  82. exception 11.1, declaration 3.1, designate 3.8, designated type 3.8, entity
  83. 3.1,  entry  9.5,  entry  family 9.5, evaluation 4.5, formal parameter 6.1,
  84. function call 6.4, identifier 2.3, indexed component 4.1.1, mode 6.1,  null
  85. access  value 3.8, object 3.2.1, operator symbol 6.1, raising of exceptions
  86. 11, renaming declarations  8.5,  selected  component  4.1.3,  slice  4.1.2,
  87. subcomponent 3.3, type 3.3
  88.  
  89. 4.1.1  Indexed Components
  90.  
  91.  
  92. An  indexed component denotes either a component of an array or an entry in
  93. a family of entries.
  94.  
  95.  
  96.     indexed_component ::= prefix(expression {, expression})
  97.  
  98.  
  99. In the case of a component of an array, the prefix must be appropriate  for
  100. an array type.  The expressions specify the index values for the component;
  101. there  must  be  one  such  expression for each index position of the array
  102. type.  In the case of an entry in a family of entries, the prefix must be a
  103. name that denotes an  entry family of a task  object,  and  the  expression
  104. (there  must  be  exactly one) specifies the index value for the individual
  105. entry.
  106.  
  107.  
  108. Each expression must be of the type of the corresponding  index.   For  the
  109. evaluation  of  an  indexed  component,  the prefix and the expressions are
  110. evaluated in some order that is not defined by the language.  The exception
  111. CONSTRAINT_ERROR is raised if an index value does not belong to  the  range
  112. of the corresponding index of the prefixing array or entry family.
  113.  
  114.  
  115. Examples of indexed components:
  116.  
  117.     MY_SCHEDULE(SAT)       --  a component of a one-dimensional array   (see 3.6.1)
  118.     PAGE(10)               --  a component of a one-dimensional array   (see 3.6)
  119.     BOARD(M, J + 1)        --  a component of a two-dimensional array   (see 3.6.1)
  120.     PAGE(10)(20)           --  a component of a component               (see 3.6)
  121.     REQUEST(MEDIUM)        --  an entry in a family of entries          (see 9.5)
  122.     NEXT_FRAME(L)(M, N)    --  a component of a function call           (see 6.1)
  123.  
  124. Notes on the examples:
  125.  
  126.  
  127. Distinct notations are used for components of multidimensional arrays (such
  128. as  BOARD) and arrays of arrays (such as PAGE).  The components of an array
  129. of arrays are arrays and  can  therefore  be  indexed.   Thus  PAGE(10)(20)
  130. denotes  the 20th component of PAGE(10).  In the last example NEXT_FRAME(L)
  131. is  a  function  call  returning  an  access  value  which   designates   a
  132. two-dimensional array.
  133.  
  134.  
  135. References:   appropriate  for  a  type 4.1, array type 3.6, component 3.3,
  136. component of an array 3.6, constraint_error exception 11.1, dimension  3.6,
  137. entry  9.5, entry family 9.5, evaluation 4.5, expression 4.4, function call
  138. 6.4, in some order 1.6,  index  3.6,  name  4.1,  prefix  4.1,  raising  of
  139. exceptions 11, returned value 5.8 6.5, task object 9.2
  140.  
  141. 4.1.2  Slices
  142.  
  143.  
  144. A slice denotes a one-dimensional array formed by a sequence of consecutive
  145. components  of  a  one-dimensional  array.   A  slice  of  a  variable is a
  146. variable;  a slice of a constant is a constant;  a slice of a  value  is  a
  147. value.
  148.  
  149.  
  150.     slice ::= prefix(discrete_range)
  151.  
  152.  
  153. The prefix of a slice must be appropriate for a one-dimensional array type.
  154. The  type  of the slice is the base type of this array type.  The bounds of
  155. the discrete range define those of the slice and must be of the type of the
  156. index;  the slice is a null slice denoting a null  array  if  the  discrete
  157. range is a null range.
  158.  
  159.  
  160. For  the  evaluation of a name that is a slice, the prefix and the discrete
  161. range are evaluated in some order that is not defined by the language.  The
  162. exception CONSTRAINT_ERROR is raised by the evaluation of  a  slice,  other
  163. than  a  null  slice,  if  any of the bounds of the discrete range does not
  164. belong to the index range of the prefixing array.  (The bounds  of  a  null
  165. slice need not belong to the subtype of the index.)
  166.  
  167.  
  168. Examples of slices:
  169.  
  170.     STARS(1 .. 15)         --  a slice of 15 characters         (see 3.6.3)
  171.     PAGE(10 .. 10 + SIZE)  --  a slice of 1 + SIZE components   (see 3.6 and 3.2.1)
  172.     PAGE(L)(A .. B)        --  a slice of the array PAGE(L)     (see 3.6)
  173.     STARS(1 .. 0)          --  a null slice                     (see 3.6.3)
  174.     MY_SCHEDULE(WEEKDAY)   --  bounds given by subtype          (see 3.6 and 3.5.1)
  175.     STARS(5 .. 15)(K)      --  same as STARS(K)                 (see 3.6.3)
  176.                            --  provided that K is in 5 .. 15
  177.  
  178. Notes:
  179.  
  180.  
  181. For  a  one-dimensional  array  A,  the  name  A(N  .. N) is a slice of one
  182. component;  its type is the base type of A.  On the other hand, A(N)  is  a
  183. component of the array A and has the corresponding component type.
  184.  
  185.  
  186. References:   appropriate  for a type 4.1, array 3.6, array type 3.6, array
  187. value 3.8, base type 3.3, belong to a subtype  3.3,  bound  of  a  discrete
  188. range  3.6.1, component 3.3, component type 3.3, constant 3.2.1, constraint
  189. 3.3, constraint_error exception 11.1, dimension 3.6,  discrete  range  3.6,
  190. evaluation  4.5,  index  3.6,  index range 3.6, name 4.1, null array 3.6.1,
  191. null range 3.5, prefix 4.1, raising of exceptions 11,  type  3.3,  variable
  192. 3.2.1
  193.  
  194. 4.1.3  Selected Components
  195.  
  196.  
  197. Selected  components  are  used to denote record components, entries, entry
  198. families, and objects designated by access values; they are  also  used  as
  199. expanded names as described below.
  200.  
  201.  
  202.     selected_component ::= prefix.selector
  203.  
  204.     selector ::= simple_name
  205.        | character_literal | operator_symbol | all
  206.  
  207.  
  208. The  following  four  forms  of  selected  components  are used to denote a
  209. discriminant, a record component, an entry, or an object designated  by  an
  210. access value:
  211.  
  212.  
  213. (a)  A discriminant:
  214.  
  215.  
  216.      The  selector  must  be  a  simple  name denoting a discriminant of an
  217.      object or value.  The prefix must be appropriate for the type of  this
  218.      object or value.
  219.  
  220.  
  221. (b)  A component of a record:
  222.  
  223.  
  224.      The  selector  must  be a simple name denoting a component of a record
  225.      object or value.  The prefix must be appropriate for the type of  this
  226.      object or value.
  227.  
  228.  
  229.      For  a  component of a variant, a check is made that the values of the
  230.      discriminants are such  that  the  record  has  this  component.   The
  231.      exception CONSTRAINT_ERROR is raised if this check fails.
  232.  
  233.  
  234. (c)  A single entry or an entry family of a task:
  235.  
  236.  
  237.      The selector must be a simple name denoting a single entry or an entry
  238.      family of a task.  The prefix must be appropriate for the type of this
  239.      task.
  240.  
  241.  
  242. (d)  An object designated by an access value:
  243.  
  244.  
  245.      The  selector  must be the reserved word all.  The value of the prefix
  246.      must belong to an access type.
  247.  
  248.  
  249. A selected component of one  of  the  remaining  two  forms  is  called  an
  250. expanded  name.   In each case the selector must be either a simple name, a
  251. character literal, or an operator symbol.  A function call is  not  allowed
  252. as the prefix of an expanded name.  An expanded name can denote:
  253.  
  254.  
  255. (e)  An entity declared in the visible part of a package:
  256.  
  257.  
  258.      The  prefix  must denote the package.  The selector must be the simple
  259.      name, character literal, or operator symbol of the entity.
  260.  
  261.  
  262. (f)  An  entity  whose  declaration  occurs  immediately  within  a   named
  263.      construct:
  264.  
  265.  
  266.      The  prefix  must  denote a construct that is either a program unit, a
  267.      block statement, a loop statement, or an  accept  statement.   In  the
  268.      case of an accept statement, the prefix must be either the simple name
  269.      of  the  entry or entry family, or an expanded name ending with such a
  270.      simple name (that is, no index is allowed).  The selector must be  the
  271.      simple  name, character literal, or operator symbol of an entity whose
  272.      declaration occurs immediately within the construct.
  273.  
  274.  
  275.      This form of expanded name is only allowed within the construct itself
  276.      (including the body and any subunits, in the case of a program  unit).
  277.      A  name  declared  by  a  renaming  declaration  is not allowed as the
  278.      prefix.  If the prefix is the name of a subprogram or accept statement
  279.      and if there is more than one visible enclosing subprogram  or  accept
  280.      statement  of this name, the expanded name is ambiguous, independently
  281.      of the selector.
  282.  
  283.  
  284. If, according to the visibility rules,  there  is  at  least  one  possible
  285. interpretation  of  the  prefix  of  a selected component as the name of an
  286. enclosing subprogram or accept statement,  then  the  only  interpretations
  287. considered  are those of rule (f), as expanded names (no interpretations of
  288. the prefix as a function call are then considered).
  289.  
  290.  
  291. The evaluation of  a  name  that  is  a  selected  component  includes  the
  292. evaluation of the prefix.
  293.  
  294.  
  295. Examples of selected components:
  296.  
  297.     TOMORROW.MONTH     --  a record component                    (see 3.7)
  298.     NEXT_CAR.OWNER     --  a record component                    (see 3.8.1)
  299.     NEXT_CAR.OWNER.AGE --  a record component                    (see 3.8.1)
  300.     WRITER.UNIT        --  a record component (a discriminant)   (see 3.7.3)
  301.     MIN_CELL(H).VALUE  --  a record component of the result      (see 6.1 and 3.8.1)
  302.                        --  of the function call MIN_CELL(H)
  303.  
  304.     CONTROL.SEIZE      --  an entry of the task CONTROL          (see 9.1 and 9.2)
  305.     POOL(K).WRITE      --  an entry of the task POOL(K)          (see 9.1 and 9.2)
  306.  
  307.     NEXT_CAR.all       --  the object designated by
  308.                        --  the access variable NEXT_CAR          (see 3.8.1)
  309.  
  310.  
  311. Examples of expanded names:
  312.  
  313.     TABLE_MANAGER.INSERT --  a procedure of the visible part of a package (see 7.5)
  314.     KEY_MANAGER."<"      --  an operator of the visible part of a package (see 7.4.2)
  315.  
  316.     DOT_PRODUCT.SUM      --  a variable declared in a procedure body      (see 6.5)
  317.     BUFFER.POOL          --  a variable declared in a task unit           (see 9.12)
  318.     BUFFER.READ          --  an entry of a task unit                      (see 9.12)
  319.     SWAP.TEMP            --  a variable declared in a block statement     (see 5.6)
  320.     STANDARD.BOOLEAN     --  the name of a predefined type                (see 8.6 and C)
  321.  
  322. Note:
  323.  
  324.  
  325. For  a record with components that are other records, the above rules imply
  326. that the simple name must be  given  at  each  level  for  the  name  of  a
  327. subcomponent.   For  example, the name NEXT_CAR.OWNER.BIRTH.MONTH cannot be
  328. shortened (NEXT_CAR.OWNER.MONTH is not allowed).
  329.  
  330.  
  331. References:  accept statement 9.5,  access  type  3.8,  access  value  3.8,
  332. appropriate  for  a  type  4.1, block statement 5.6, body of a program unit
  333. 3.9, character literal 2.5, component of  a  record  3.7,  constraint_error
  334. exception  11.1,  declaration  3.1, designate 3.8, discriminant 3.3, entity
  335. 3.1, entry 9.5, entry family  9.5,  function  call  6.4,  index  3.6,  loop
  336. statement  5.5,  object  3.2.1, occur immediately within 8.1, operator 4.5,
  337. operator symbol 6.1, overloading 8.3, package 7, predefined type C,  prefix
  338. 4.1,  procedure  body 6.3, program unit 6, raising of exceptions 11, record
  339. 3.7, record component 3.7, renaming declaration  8.5,  reserved  word  2.9,
  340. simple  name 4.1, subprogram 6, subunit 10.2, task 9, task object 9.2, task
  341. unit 9, variable 3.7.3, variant 3.7.3, visibility 8.3, visible part 3.7.3
  342.  
  343. 4.1.4  Attributes
  344.  
  345.  
  346. An attribute denotes a basic operation of an entity given by a prefix.
  347.  
  348.  
  349.     attribute ::= prefix'attribute_designator
  350.  
  351.     attribute_designator ::= simple_name [(universal_static_expression)]
  352.  
  353.  
  354. The applicable attribute designators depend on the  prefix.   An  attribute
  355. can  be  a  basic  operation delivering a value;  alternatively it can be a
  356. function, a type, or a range.  The meaning of the prefix  of  an  attribute
  357. must   be  determinable  independently  of  the  attribute  designator  and
  358. independently of the fact that it is the prefix of an attribute.
  359.  
  360.  
  361. The attributes defined by the language  are  summarized  in  Annex  A.   In
  362. addition,  an implementation may provide implementation-defined attributes;
  363. their description must be given in Appendix F.  The attribute designator of
  364. any implementation-defined attribute must not be the same as  that  of  any
  365. language-defined attribute.
  366.  
  367.  
  368. The evaluation of a name that is an attribute consists of the evaluation of
  369. the prefix.
  370.  
  371. Notes:
  372.  
  373.  
  374. The attribute designators DIGITS, DELTA, and RANGE have the same identifier
  375. as  a  reserved word.  However, no confusion is possible since an attribute
  376. designator is always  preceded  by  an  apostrophe.   The  only  predefined
  377. attribute  designators  that  have  a  universal  expression  are those for
  378. certain operations of array types (see 3.6.2).
  379.  
  380.  
  381. Examples of attributes:
  382.  
  383.     COLOR'FIRST        -- minimum value of the enumeration type COLOR  (see 3.3.1 and 3.5)
  384.     RAINBOW'BASE'FIRST -- same as COLOR'FIRST                          (see 3.3.2 and 3.3.3)
  385.     REAL'DIGITS        -- precision of the type REAL                   (see 3.5.7 and 3.5.8)
  386.     BOARD'LAST(2)      -- upper bound of the second dimension of BOARD (see 3.6.1 and 3.6.2)
  387.     BOARD'RANGE(1)     -- index range of the first dimension of BOARD  (see 3.6.1 and 3.6.2)
  388.     POOL(K)'TERMINATED -- TRUE if task POOL(K) is terminated           (see 9.2   and 9.9)
  389.     DATE'SIZE          -- number of bits for records of type DATE      (see 3.7   and 13.7.2)
  390.     MESSAGE'ADDRESS    -- address of the record variable MESSAGE       (see 3.7.2 and 13.7.2)
  391.  
  392.  
  393. References:  appropriate for a type 4.1, basic  operation  3.3.3,  declared
  394. entity  3.1,  name  4.1,  prefix  4.1,  reserved word 2.9, simple name 4.1,
  395. static expression 4.9, type 3.3, universal expression 4.10
  396.  
  397. 4.2  Literals
  398.  
  399.  
  400. A literal is either a numeric literal, an enumeration literal, the  literal
  401. null,  or  a  string  literal.   The  evaluation  of  a  literal yields the
  402. corresponding value.
  403.  
  404.  
  405. Numeric literals are  the  literals  of  the  types  universal_integer  and
  406. universal_real.   Enumeration literals include character literals and yield
  407. values of the corresponding enumeration types.  The literal null  yields  a
  408. null access value which designates no objects at all.
  409.  
  410.  
  411. A  string  literal  is  a  basic  operation  that  combines  a  sequence of
  412. characters into a value of a one-dimensional array  of  a  character  type;
  413. the  bounds  of  this  array  are  determined  according  to  the rules for
  414. positional array aggregates (see 4.3.2).  For a null  string  literal,  the
  415. upper  bound  is  the  predecessor,  as given by the PRED attribute, of the
  416. lower bound.  The evaluation of a null string literal raises the  exception
  417. CONSTRAINT_ERROR  if  the  lower  bound  does  not  have a predecessor (see
  418. 3.5.5).
  419.  
  420.  
  421. The type of a string literal and likewise the type of the literal null must
  422. be determinable solely from the context  in  which  this  literal  appears,
  423. excluding the literal itself, but using the fact that the literal null is a
  424. value  of an access type, and similarly that a string literal is a value of
  425. a one-dimensional array type whose component type is a character type.
  426.  
  427.  
  428. The character literals corresponding to the  graphic  characters  contained
  429. within  a string literal must be visible at the place of the string literal
  430. (although these characters themselves are not used to determine the type of
  431. the string literal).
  432.  
  433.  
  434. Examples:
  435.  
  436.     3.14159_26536  --  a real literal
  437.     1_345          --  an integer literal
  438.     CLUBS          --  an enumeration literal
  439.     'A'            --  a character literal
  440.     "SOME TEXT"    --  a string literal
  441.  
  442.  
  443. References:  access type 3.8, aggregate 4.3, array 3.6,  array  bound  3.6,
  444. array type 3.6, character literal 2.5, character type 3.5.2, component type
  445. 3.3,   constraint_error  exception  11.1,  designate  3.8,  dimension  3.6,
  446. enumeration literal 3.5.1, graphic character 2.1, integer literal 2.4, null
  447. access value 3.8, null literal 3.8, numeric literal 2.4, object 3.2.1, real
  448. literal 2.4, string literal 2.6, type 3.3,  universal_integer  type  3.5.4,
  449. universal_real type 3.5.6, visibility 8.3
  450.  
  451. 4.3  Aggregates
  452.  
  453.  
  454. An  aggregate  is  a  basic operation that combines component values into a
  455. composite value of a record or array type.
  456.  
  457.  
  458.     aggregate ::=
  459.        (component_association {, component_association})
  460.  
  461.     component_association ::=
  462.        [choice {| choice} => ] expression
  463.  
  464.  
  465. Each  component  association  associates  an  expression  with   components
  466. (possibly  none).   A  component  association  is  said  to be named if the
  467. components are specified explicitly by choices;  it is otherwise said to be
  468. positional.  For  a  positional  association,  the  (single)  component  is
  469. implicitly  specified  by  position,  in  the  order  of  the corresponding
  470. component declarations for record components,  in  index  order  for  array
  471. components.
  472.  
  473.  
  474. Named  associations  can  be  given  in  any  order  (except for the choice
  475. others), but if both positional and named associations are used in the same
  476. aggregate, then positional associations must occur first, at  their  normal
  477. position.   Hence  once  a  named  association  is  used,  the  rest of the
  478. aggregate must use only named associations.  Aggregates containing a single
  479. component association must always be given  in  named  notation.   Specific
  480. rules  concerning  component  associations  exist for record aggregates and
  481. array aggregates.
  482.  
  483.  
  484. Choices in component associations have the same syntax as in variant  parts
  485. (see 3.7.3).  A choice that is a component simple name is only allowed in a
  486. record  aggregate.   For a component association, a choice that is a simple
  487. expression or a discrete range is only allowed in an  array  aggregate;   a
  488. choice  that  is  a  simple  expression  specifies  the  component  at  the
  489. corresponding index  value;   similarly  a  discrete  range  specifies  the
  490. components  at  the  index  values in the range.  The choice others is only
  491. allowed in a component association if the association appears last and  has
  492. this single choice;  it specifies all remaining components, if any.        
  493.  
  494.  
  495. Each  component  of  the  value defined by an aggregate must be represented
  496. once and only once in the aggregate.  Hence each aggregate must be complete
  497. and a given component is not allowed to  be  specified  by  more  than  one
  498. choice.
  499.  
  500.  
  501. The  type  of  an aggregate must be determinable solely from the context in
  502. which the aggregate appears, excluding the aggregate itself, but using  the
  503. fact  that  this  type  must  be composite and not limited.  The type of an
  504. aggregate in turn determines the required type for each of its  components.
  505.  
  506. Notes:
  507.  
  508.  
  509. The  above  rule implies that the determination of the type of an aggregate
  510. cannot use any information from within the aggregate.  In particular,  this
  511. determination  cannot  use  the  type  of  the  expression  of  a component
  512. association, or the form or the type of a choice.  An aggregate can  always
  513. be  distinguished  from  an  expression enclosed by parentheses:  this is a
  514. consequence of the fact that named notation is required  for  an  aggregate
  515. with a single component.
  516.  
  517.  
  518. References:   array aggregate 4.3.2, array type 3.6, basic operation 3.3.3,
  519. choice 3.7.3, component 3.3,  composite  type  3.3,  composite  value  3.3,
  520. discrete  range 3.6, expression 4.4, index 3.6, limited type 7.4.4, primary
  521. 4.4, record aggregate 4.3.1, record type 3.7, simple expression 4.4, simple
  522. name 4.1, type 3.3, variant part 3.7.3
  523.  
  524. 4.3.1  Record Aggregates
  525.  
  526.  
  527. If the type of an aggregate is a record type, the component names given  as
  528. choices  must  denote  components  (including  discriminants) of the record
  529. type.  If the choice others is given as a choice of a record aggregate,  it
  530. must  represent  at  least one component.  A component association with the
  531. choice others or  with  more  than  one  choice  is  only  allowed  if  the
  532. represented  components  are  all  of  the  same type.  The expression of a
  533. component  association  must  have  the  type  of  the  associated   record
  534. components.
  535.  
  536.  
  537. The  value specified for a discriminant that governs a variant part must be
  538. given by a  static  expression  (note  that  this  value  determines  which
  539. dependent components must appear in the record value).
  540.  
  541.  
  542. For  the  evaluation  of  a  record aggregate, the expressions given in the
  543. component associations are evaluated in some order that is not  defined  by
  544. the  language.  The expression of a named association is evaluated once for
  545. each associated component.   A  check  is  made  that  the  value  of  each
  546. subcomponent  of the aggregate belongs to the subtype of this subcomponent.
  547. The exception CONSTRAINT_ERROR is raised if this check fails.
  548.  
  549.  
  550. Example of a record aggregate with positional associations:
  551.  
  552.     (4, JULY, 1776)                      --  see 3.7
  553.  
  554.  
  555. Examples of record aggregates with named associations:
  556.  
  557.     (DAY => 4, MONTH => JULY, YEAR => 1776)
  558.     (MONTH => JULY, DAY => 4, YEAR => 1776)
  559.  
  560.     (DISK, CLOSED, TRACK => 5, CYLINDER => 12)       --  see 3.7.3
  561.     (UNIT => DISK, STATUS => CLOSED, CYLINDER => 9, TRACK => 1)
  562.  
  563.  
  564. Example of component association with several choices:
  565.  
  566.     (VALUE => 0, SUCC|PRED => new CELL'(0, null, null))        --  see 3.8.1
  567.     --  The allocator is evaluated twice:  SUCC and PRED designate different cells
  568.  
  569. Note:
  570.  
  571.  
  572. For an aggregate with positional associations, discriminant  values  appear
  573. first  since  the  discriminant  part  is  given  first  in the record type
  574. declaration;  they must be in the same order as in the  discriminant  part.
  575.  
  576.  
  577. References:    aggregate   4.3,  allocator  4.8,  choice  3.7.3,  component
  578. association 4.3,  component  name  3.7,  constraint  3.3,  constraint_error
  579. exception   11.1,   depend  on  a  discriminant  3.7.1,  discriminant  3.3,
  580. discriminant part 3.7.1, evaluate 4.5, expression 4.4, in some  order  1.6,
  581. program  10,  raising  of  exceptions 11, record component 3.7, record type
  582. 3.7, satisfy 3.3, static expression 4.9, subcomponent 3.3,  subtype  3.3.2,
  583. type 3.3, variant part 3.7.3
  584.  
  585. 4.3.2  Array Aggregates
  586.  
  587.  
  588. If  the  type  of  an  aggregate is a one-dimensional array type, then each
  589. choice must specify values of the index type, and the  expression  of  each
  590. component association must be of the component type.
  591.  
  592.  
  593. If  the  type  of  an  aggregate  is  a  multidimensional  array  type,  an
  594. n-dimensional aggregate is written as a one-dimensional aggregate, in which
  595. the expression specified for each component association is  itself  written
  596. as  an  (n-1)-dimensional  aggregate  which  is called a subaggregate;  the
  597. index subtype of the one-dimensional aggregate is given by the first  index
  598. position  of the array type.  The same rule is used to write a subaggregate
  599. if it is again  multidimensional,  using  successive  index  positions.   A
  600. string literal is allowed in a multidimensional aggregate at the place of a
  601. one-dimensional  array  of  a  character  type.  In what follows, the rules
  602. concerning array aggregates are  formulated  in  terms  of  one-dimensional
  603. aggregates.
  604.  
  605.  
  606. Apart from a final component association with the single choice others, the
  607. rest  (if  any) of the component associations of an array aggregate must be
  608. either all positional or all  named.   A  named  association  of  an  array
  609. aggregate  is only allowed to have a choice that is not static, or likewise
  610. a choice that is a null range, if the aggregate includes a single component
  611. association and this component association has a single choice.  An  others
  612. choice is static if the applicable index constraint is static.
  613.  
  614.  
  615. The  bounds  of an array aggregate that has an others choice are determined
  616. by the applicable index constraint.  An others choice is  only  allowed  if
  617. the  aggregate  appears in one of the following contexts (which defines the
  618. applicable index constraint):
  619.  
  620.  
  621. (a)  The aggregate is an actual parameter, a generic actual parameter,  the
  622.      result  expression  of  a  function, or the expression that follows an
  623.      assignment  compound  delimiter.   Moreover,  the   subtype   of   the
  624.      corresponding  formal  parameter,  generic  formal parameter, function
  625.      result, or object is a constrained array subtype.
  626.  
  627.  
  628.      For an aggregate that appears  in  such  a  context  and  contains  an
  629.      association  with an others choice, named associations are allowed for
  630.      other associations only in the case of a (nongeneric) actual parameter
  631.      or function result.  If the aggregate  is  a  multidimensional  array,
  632.      this restriction also applies to each of its subaggregates.
  633.  
  634.  
  635. (b)  The aggregate is the operand of a qualified expression whose type mark
  636.      denotes a constrained array subtype.
  637.  
  638.  
  639. (c)  The aggregate is the expression of the  component  association  of  an
  640.      enclosing  (array  or  record) aggregate.  Moreover, if this enclosing
  641.      aggregate is a multidimensional array aggregate then it is  itself  in
  642.      one of these three contexts.
  643.  
  644.  
  645. The  bounds  of  an array aggregate that does not have an others choice are
  646. determined as follows.  For an aggregate that has named  associations,  the
  647. bounds  are  determined  by  the smallest and largest choices given.  For a
  648. positional aggregate, the lower bound is determined by the applicable index
  649. constraint if the aggregate appears in one of the contexts (a) through (c);
  650. otherwise, the lower bound is  given  by  S'FIRST  where  S  is  the  index
  651. subtype;   in  either  case, the upper bound is determined by the number of
  652. components.
  653.  
  654.  
  655. The evaluation of an array aggregate that is not a subaggregate proceeds in
  656. two steps.  First, the choices of this aggregate and of its  subaggregates,
  657. if  any,  are  evaluated in some order that is not defined by the language.
  658. Second,  the  expressions  of  the  component  associations  of  the  array
  659. aggregate  are evaluated in some order that is not defined by the language;
  660. the expression of a named association is evaluated once for each associated
  661. component.  The evaluation of a subaggregate consists of this  second  step
  662. (the  first step is omitted since the choices have already been evaluated).
  663.  
  664.  
  665. For the evaluation of an aggregate that is not a null  array,  a  check  is
  666. made  that  the index values defined by choices belong to the corresponding
  667. index subtypes, and also  that  the  value  of  each  subcomponent  of  the
  668. aggregate   belongs   to   the   subtype  of  this  subcomponent.   For  an
  669. n-dimensional  multidimensional  aggregate,  a  check  is  made  that   all
  670. (n-1)-dimensional  subaggregates  have  the  same  bounds.   The  exception
  671. CONSTRAINT_ERROR is raised if any of these checks fails.
  672.  
  673. Note:
  674.  
  675.  
  676. The allowed contexts for an array aggregate including an others choice  are
  677. such  that  the  bounds  of  such  an  aggregate  are always known from the
  678. context.
  679.  
  680.  
  681. Examples of array aggregates with positional associations:
  682.  
  683.     (7, 9, 5, 1, 3, 2, 4, 8, 6, 0)
  684.     TABLE'(5, 8, 4, 1, others => 0)  --  see 3.6
  685.  
  686.  
  687. Examples of array aggregates with named associations:
  688.  
  689.     (1 .. 5 => (1 .. 8 => 0.0))     --  two-dimensional
  690.     (1 .. N => new CELL)            --  N new cells, in particular for N = 0
  691.  
  692.     TABLE'(2 | 4 | 10 => 1, others => 0)
  693.     SCHEDULE'(MON .. FRI => TRUE,  others => FALSE)  --  see 3.6
  694.     SCHEDULE'(WED | SUN  => FALSE, others => TRUE)
  695.  
  696.  
  697. Examples of two-dimensional array aggregates:
  698.  
  699.     -- Three aggregates for the same value of type MATRIX (see 3.6):
  700.  
  701.     ((1.1, 1.2, 1.3), (2.1, 2.2, 2.3))
  702.     (1 => (1.1, 1.2, 1.3), 2 => (2.1, 2.2, 2.3))
  703.     (1 => (1 => 1.1, 2 => 1.2, 3 => 1.3), 2 => (1 => 2.1, 2 => 2.2, 3 => 2.3))
  704.  
  705.  
  706. Examples of aggregates as initial values:
  707.  
  708.     A : TABLE := (7, 9, 5, 1, 3, 2, 4, 8, 6, 0);        -- A(1)=7, A(10)=0
  709.     B : TABLE := TABLE'(2 | 4 | 10 => 1, others => 0);  -- B(1)=0, B(10)=1
  710.     C : constant MATRIX := (1 .. 5 => (1 .. 8 => 0.0)); -- C'FIRST(1)=1, C'LAST(2)=8
  711.  
  712.     D : BIT_VECTOR(M .. N) := (M .. N => TRUE);  -- see 3.6
  713.     E : BIT_VECTOR(M .. N) := (others => TRUE);
  714.     F : STRING(1 .. 1) := (1 => 'F');  -- a one component aggregate: same as "F"
  715.  
  716.  
  717. References:   actual  parameter  6.4.1,  aggregate  4.3,  array  type  3.6,
  718. assignment  compound  delimiter 5.2, choice 3.7.3, component 3.3, component
  719. association  4.3,  component  type  3.3,  constrained  array  subtype  3.6,
  720. constraint  3.3,  constraint_error  exception 11.1, dimension 3.6, evaluate
  721. 4.5, expression 4.4, formal parameter 6.1, function 6.5, in some order 1.6,
  722. index constraint 3.6.1, index range 3.6, index subtype 3.6, index type 3.6,
  723. named component association 4.3, null array 3.6.1, object  3.2,  positional
  724. component  association 4.3, qualified expression 4.7, raising of exceptions
  725. 11, static expression 4.9, subcomponent 3.3, type 3.3
  726.  
  727. 4.4  Expressions
  728.  
  729.  
  730. An expression is a formula that defines the computation of a value.
  731.  
  732.  
  733.     expression ::=
  734.          relation {and relation} | relation {and then relation}
  735.        | relation {or relation}  | relation {or else relation}
  736.        | relation {xor relation}
  737.  
  738.     relation ::=
  739.          simple_expression [relational_operator simple_expression]
  740.        | simple_expression [not] in range
  741.        | simple_expression [not] in type_mark
  742.  
  743.     simple_expression ::= [unary_adding_operator] term {binary_adding_operator term}
  744.  
  745.     term ::= factor {multiplying_operator factor}
  746.  
  747.     factor ::= primary [** primary] | abs primary | not primary
  748.  
  749.     primary ::=
  750.          numeric_literal | null | aggregate | string_literal | name | allocator
  751.        | function_call | type_conversion | qualified_expression | (expression)
  752.  
  753.  
  754. Each primary has a value and a type.  The only names allowed  as  primaries
  755. are  named  numbers;   attributes  that  yield  values;  and names denoting
  756. objects (the value of such a  primary  is  the  value  of  the  object)  or
  757. denoting  values.   Names that denote formal parameters of mode out are not
  758. allowed as primaries;  names of their subcomponents are only allowed in the
  759. case of discriminants.
  760.  
  761.  
  762. The type of an expression depends only on the type of its constituents  and
  763. on  the  operators applied;  for an overloaded constituent or operator, the
  764. determination of  the  constituent  type,  or  the  identification  of  the
  765. appropriate   operator,  depends  on  the  context.   For  each  predefined
  766. operator, the operand and result types are given in section 4.5.
  767.  
  768.  
  769. Examples of primaries:
  770.  
  771.     4.0                --  real literal
  772.     PI                 --  named number
  773.     (1 .. 10 => 0)     --  array aggregate
  774.     SUM                --  variable
  775.     INTEGER'LAST       --  attribute
  776.     SINE(X)            --  function call
  777.     COLOR'(BLUE)       --  qualified expression
  778.     REAL(M*N)          --  conversion
  779.     (LINE_COUNT + 10)  --  parenthesized expression
  780.  
  781.  
  782. Examples of expressions:
  783.  
  784.     VOLUME                  -- primary
  785.     not DESTROYED           -- factor
  786.     2*LINE_COUNT            -- term
  787.     -4.0                      -- simple expression
  788.     -4.0 + A                  -- simple expression
  789.     B**2 - 4.0*A*C            -- simple expression
  790.     PASSWORD(1 .. 3) = "BWV"    -- relation
  791.     COUNT in SMALL_INT          -- relation
  792.     COUNT not in SMALL_INT      -- relation
  793.     INDEX = 0 or ITEM_HIT         -- expression
  794.     (COLD and SUNNY) or WARM      -- expression (parentheses are required)
  795.     A**(B**C)                     -- expression (parentheses are required)
  796.  
  797.  
  798. References:  aggregate 4.3, allocator 4.8, array aggregate 4.3.2, attribute
  799. 4.1.4, binary adding operator 4.5 4.5.3,  context  of  overload  resolution
  800. 8.7,  exponentiating  operator  4.5  4.5.6,  function call 6.4, multiplying
  801. operator 4.5 4.5.5, name 4.1, named number 3.2, null literal  3.8,  numeric
  802. literal  2.4,  object  3.2,  operator  4.5, overloading 8.3, overloading an
  803. operator 6.7, qualified  expression  4.7,  range  3.5,  real  literal  2.4,
  804. relation  4.5.1,  relational  operator  4.5  4.5.2, result type 6.1, string
  805. literal 2.6, type 3.3, type conversion 4.6, type mark 3.3.2,  unary  adding
  806. operator 4.5 4.5.4, variable 3.2.1
  807.  
  808. 4.5  Operators and Expression Evaluation
  809.  
  810.  
  811. The   language  defines  the  following  six  classes  of  operators.   The
  812. corresponding operator symbols (except /=), and only those, can be used  as
  813. designators  in declarations of functions for user-defined operators.  They
  814. are given in the order of increasing precedence.
  815.  
  816.  
  817.     logical_operator             ::=  and | or  | xor
  818.  
  819.     relational_operator          ::=  =   | /=  | <   | <= | > | >=
  820.  
  821.     binary_adding_operator       ::=  +   | -   | &
  822.  
  823.     unary_adding_operator        ::=  +   | -
  824.  
  825.     multiplying_operator         ::=  *   | /   | mod | rem
  826.  
  827.     highest_precedence_operator  ::=  **  | abs | not
  828.  
  829.  
  830. The short-circuit control  forms  and  then  and  or  else  have  the  same
  831. precedence  as  logical operators.  The membership tests in and not in have
  832. the same precedence as relational operators.
  833.  
  834.  
  835. For a term, simple expression, relation, or expression, operators of higher
  836. precedence are associated with their operands  before  operators  of  lower
  837. precedence.   In  this  case,  for  a  sequence  of  operators  of the same
  838. precedence level, the operators are associated in textual order  from  left
  839. to right;  parentheses can be used to impose specific associations.
  840.  
  841.  
  842. The  operands  of  a  factor,  of  a  term, of a simple expression, or of a
  843. relation, and the operands  of  an  expression  that  does  not  contain  a
  844. short-circuit control form, are evaluated in some order that is not defined
  845. by  the  language  (but  before application of the corresponding operator).
  846. The right operand of a short-circuit control form is evaluated if and  only
  847. if the left operand has a certain value (see 4.5.1).
  848.  
  849.  
  850. For  each  form  of  type  declaration,  certain of the above operators are
  851. predefined, that is, they are implicitly declared by the type  declaration.
  852. For  each  such  implicit operator declaration, the names of the parameters
  853. are LEFT and RIGHT for binary operators;  the single  parameter  is  called
  854. RIGHT  for  unary adding operators and for the unary operators abs and not.
  855. The effect of the predefined operators is explained  in  subsections  4.5.1
  856. through 4.5.7.                                                             
  857.  
  858.  
  859. The  predefined operations on integer types either yield the mathematically
  860. correct  result  or  raise  the  exception  NUMERIC_ERROR.   A   predefined
  861. operation   that   delivers  a  result  of  an  integer  type  (other  than
  862. universal_integer) can  only  raise  the  exception  NUMERIC_ERROR  if  the
  863. mathematical  result is not a value of the type.  The predefined operations
  864. on real types yield results whose accuracy is defined in section 4.5.7.   A
  865. predefined  operation  that  delivers  a  result of a real type (other than
  866. universal_real) can only raise the exception NUMERIC_ERROR if the result is
  867. not within the range of the safe numbers  of  the  type,  as  explained  in
  868. section 4.5.7.
  869.  
  870.  
  871. Examples of precedence:
  872.  
  873.     not SUNNY or WARM    --  same as (not SUNNY) or WARM
  874.     X > 4.0 and Y > 0.0  --  same as (X > 4.0) and (Y > 0.0)
  875.  
  876.     -4.0*A**2            --  same as -(4.0 * (A**2))
  877.     abs(1 + A) + B       --  same as (abs (1 + A)) + B
  878.     Y**(-3)              --  parentheses are necessary
  879.     A / B * C            --  same as (A/B)*C
  880.     A + (B + C)          --  evaluate B + C before adding it to A
  881.  
  882.  
  883. References:    designator   6.1,   expression  4.4,  factor  4.4,  implicit
  884. declaration 3.1, in some order 1.6, integer  type  3.5.4,  membership  test
  885. 4.5.2, name 4.1, numeric_error exception 11.1, overloading 6.6 8.7, raising
  886. of  an  exception 11, range 3.5, real type 3.5.6, relation 4.4, safe number
  887. 3.5.6, short-circuit control form 4.5 4.5.1, simple  expression  4.4,  term
  888. 4.4,  type  3.3,  type  declaration  3.3.1,  universal_integer  type 3.5.4,
  889. universal_real type 3.5.6
  890.  
  891. 4.5.1  Logical Operators and Short-circuit Control Forms
  892.  
  893.  
  894. The following logical operators are predefined for any boolean type and any
  895. one-dimensional array type whose components are  of  a  boolean  type;   in
  896. either case the two operands have the same type.
  897.  
  898.  
  899.     Operator   Operation               Operand type                  Result type
  900.  
  901.     and        conjunction             any boolean type              same boolean type
  902.                                        array of boolean components   same array type
  903.  
  904.     or         inclusive disjunction   any boolean type              same boolean type
  905.                                        array of boolean components   same array type
  906.  
  907.     xor        exclusive disjunction   any boolean type              same boolean type
  908.                                        array of boolean components   same array type
  909.  
  910.  
  911. The operations on arrays are performed on a component-by-component basis on
  912. matching  components,  if  any (as for equality, see 4.5.2).  The bounds of
  913. the resulting array are those of the left operand.  A check  is  made  that
  914. for each component of the left operand there is a matching component of the
  915. right operand, and vice versa.  The exception CONSTRAINT_ERROR is raised if
  916. this check fails.
  917.  
  918.  
  919. The  short-circuit  control  forms and then and or else are defined for two
  920. operands of a boolean type and deliver a result of the same type.  The left
  921. operand of a short-circuit control form is always evaluated first.  If  the
  922. left  operand  of an expression with the control form and then evaluates to
  923. FALSE, the right operand is not evaluated and the value of  the  expression
  924. is  FALSE.   If  the left operand of an expression with the control form or
  925. else evaluates to TRUE, the right operand is not evaluated and the value of
  926. the expression is TRUE.  If both operands are evaluated, and then  delivers
  927. the same result as and, and or else delivers the same result as or.
  928.  
  929.  
  930. Note:  The  conventional  meaning  of the logical operators is given by the
  931. following truth table:
  932.  
  933.  
  934.     A        B       (A and B)    (A or B)    (A xor B)
  935.  
  936.     TRUE    TRUE     TRUE         TRUE        FALSE
  937.     TRUE    FALSE    FALSE        TRUE        TRUE
  938.     FALSE   TRUE     FALSE        TRUE        TRUE
  939.     FALSE   FALSE    FALSE        FALSE       FALSE
  940.  
  941.  
  942. Examples of logical operators:
  943.  
  944.     SUNNY or WARM
  945.     FILTER(1 .. 10) and FILTER(15 .. 24)   --   see 3.6.1
  946.  
  947.  
  948. Examples of short-circuit control forms:
  949.  
  950.     NEXT_CAR.OWNER /= null and then NEXT_CAR.OWNER.AGE > 25   --   see 3.8.1
  951.     N = 0 or else A(N) = HIT_VALUE
  952.  
  953.  
  954. References:  array type 3.6, boolean type 3.5.3, bound of  an  index  range
  955. 3.6.1,   component  of  an  array  3.6,  constraint_error  exception  11.1,
  956. dimension 3.6, false boolean  value  3.5.3,  index  subtype  3.6,  matching
  957. components  of arrays 4.5.2, null array 3.6.1, operation 3.3, operator 4.5,
  958. predefined operator 4.5, raising  of  exceptions  11,  true  boolean  value
  959. 3.5.3, type 3.3
  960.  
  961. 4.5.2  Relational Operators and Membership Tests
  962.  
  963.  
  964. The  equality  and inequality operators are predefined for any type that is
  965. not limited.  The other relational operators are the ordering  operators  <
  966. (less  than),  <=  (less  than or equal), > (greater than), and >= (greater
  967. than or equal).  The ordering operators   are  predefined  for  any  scalar
  968. type,  and  for  any  discrete array type, that is, a one-dimensional array
  969. type whose components are  of  a  discrete  type.   The  operands  of  each
  970. predefined  relational operator have the same type.  The result type is the
  971. predefined type BOOLEAN.
  972.  
  973.  
  974. The relational operators have their conventional meaning:   the  result  is
  975. equal  to  TRUE  if the corresponding relation is satisfied;  the result is
  976. FALSE otherwise.  The inequality operator gives the complementary result to
  977. the equality operator:  FALSE if equal, TRUE if not equal.
  978.  
  979.  
  980.     Operator    Operation                 Operand type          Result type
  981.  
  982.     = /=        equality and inequality   any type              BOOLEAN
  983.  
  984.     < <= > >=   test for ordering         any scalar type       BOOLEAN
  985.                                           discrete array type   BOOLEAN
  986.  
  987.  
  988. Equality for the discrete types  is  equality  of  the  values.   For  real
  989. operands  whose  values  are  nearly  equal,  the results of the predefined
  990. relational operators are given in section 4.5.7.   Two  access  values  are
  991. equal either if they designate the same object, or if both are equal to the
  992. null value of the access type.
  993.  
  994.  
  995. For  two  array  values  or  two  record  values of the same type, the left
  996. operand is equal to the right operand if and only if for each component  of
  997. the  left  operand  there  is a matching component of the right operand and
  998. vice versa;  and the values of matching components are equal, as  given  by
  999. the  predefined  equality  operator for the component type.  In particular,
  1000. two null arrays of the same type are always equal;  two null records of the
  1001. same type are always equal.
  1002.  
  1003.  
  1004. For comparing two records of the same type, matching components  are  those
  1005. which have the same component identifier.
  1006.  
  1007.  
  1008. For  comparing  two  one-dimensional  arrays  of  the  same  type, matching
  1009. components are those (if any) whose index values  match  in  the  following
  1010. sense:   the lower bounds of the index ranges are defined to match, and the
  1011. successors of matching indices are defined to  match.   For  comparing  two
  1012. multidimensional  arrays,  matching components are those whose index values
  1013. match in successive index positions.
  1014.  
  1015.  
  1016. If equality is explicitly defined for a limited type, it does not extend to
  1017. composite  types  having  subcomponents  of  the  limited  type   (explicit
  1018. definition of equality is allowed for such composite types).
  1019.  
  1020.  
  1021. The ordering operators <, <=, >, and >= that are defined for discrete array
  1022. types correspond to lexicographic order using the predefined order relation
  1023. of  the  component  type.   A null array is lexicographically less than any
  1024. array having at least one component.  In the case of  nonnull  arrays,  the
  1025. left  operand is lexicographically less than the right operand if the first
  1026. component of the left operand is less than that of  the  right;   otherwise
  1027. the  left  operand is lexicographically less than the right operand only if
  1028. their first components are equal and  the  tail  of  the  left  operand  is
  1029. lexicographically  less  than  that  of the right (the tail consists of the
  1030. remaining components beyond the first and can be null).
  1031.  
  1032.  
  1033. The membership tests in and not in  are  predefined  for  all  types.   The
  1034. result  type  is the predefined type BOOLEAN.  For a membership test with a
  1035. range, the simple expression and the bounds of the range  must  be  of  the
  1036. same  scalar type;  for a membership test with a type mark, the type of the
  1037. simple expression must be the base type of the type mark.   The  evaluation
  1038. of the membership test in yields the result TRUE if the value of the simple
  1039. expression  is  within  the  given  range,  or if this value belongs to the
  1040. subtype denoted by the given type mark;  otherwise this  evaluation  yields
  1041. the  result  FALSE (for a value of a real type, see 4.5.7).  The membership
  1042. test not in gives the complementary result to the membership test in.
  1043.  
  1044.  
  1045. Examples:
  1046.  
  1047.     X /= Y
  1048.  
  1049.     "" < "A" and "A" < "AA"     --  TRUE
  1050.     "AA" < "B" and "A" < "A  "  --  TRUE
  1051.  
  1052.     MY_CAR = null              -- true if MY_CAR has been set to null (see 3.8.1)
  1053.     MY_CAR = YOUR_CAR          -- true if we both share the same car
  1054.     MY_CAR.all = YOUR_CAR.all  -- true if the two cars are identical
  1055.  
  1056.     N not in 1 .. 10     -- range membership test
  1057.     TODAY in MON .. FRI  -- range membership test
  1058.     TODAY in WEEKDAY     -- subtype membership test (see 3.5.1)
  1059.     ARCHIVE in DISK_UNIT -- subtype membership test (see 3.7.3)
  1060.  
  1061. Notes:
  1062.  
  1063.  
  1064. No exception is ever raised by a predefined relational  operator  or  by  a
  1065. membership  test,  but  an exception can be raised by the evaluation of the
  1066. operands.
  1067.  
  1068.  
  1069. If a record type has components that depend on discriminants, two values of
  1070. this type have matching components if and only if their  discriminants  are
  1071. equal.   Two  nonnull  arrays  have  matching components if and only if the
  1072. value of the attribute LENGTH(N) for each index position N is the same  for
  1073. both.
  1074.  
  1075.  
  1076. References:   access  value 3.8, array type 3.6, base type 3.3, belong to a
  1077. subtype 3.3, boolean predefined type 3.5.3, bound of a range 3.5, component
  1078. 3.3, component identifier 3.7, component  type  3.3,  composite  type  3.3,
  1079. designate  3.8, dimension 3.6, discrete type 3.5, evaluation 4.5, exception
  1080. 11, index 3.6, index range 3.6, limited type 7.4.4, null access value  3.8,
  1081. null  array  3.6.1,  null record 3.7, object 3.2.1, operation 3.3, operator
  1082. 4.5, predefined operator 4.5, raising of exceptions 11, range  3.5,  record
  1083. type  3.7,  scalar  type  3.5,  simple  expression  4.4,  subcomponent 3.3,
  1084. successor 3.5.5, type 3.3, type mark 3.3.2
  1085.  
  1086. 4.5.3  Binary Adding Operators
  1087.  
  1088.  
  1089. The binary adding operators + and -  are predefined for  any  numeric  type
  1090. and  have  their  conventional  meaning.   The  catenation  operators & are
  1091. predefined for any one-dimensional array type that is not limited.
  1092.  
  1093.  
  1094.     Operator  Operation    Left operand type    Right operand type   Result type
  1095.  
  1096.     +         addition     any numeric type     same numeric type    same numeric type
  1097.  
  1098.     -         subtraction  any numeric type     same numeric type    same numeric type
  1099.  
  1100.     &         catenation   any array type       same array type      same array type
  1101.                            any array type       the component type   same array type
  1102.                            the component type   any array type       same array type
  1103.                            the component type   the component type   any array type
  1104.  
  1105.  
  1106. For real types, the accuracy of the result is  determined  by  the  operand
  1107. type (see 4.5.7).
  1108.  
  1109.  
  1110. If  both  operands are one-dimensional arrays, the result of the catenation
  1111. is a one-dimensional array whose length is the sum of the  lengths  of  its
  1112. operands,  and whose components comprise the components of the left operand
  1113. followed by the components of the right operand.  The lower bound  of  this
  1114. result is the lower bound of the left operand, unless the left operand is a
  1115. null  array,  in  which  case  the  result  of  the catenation is the right
  1116. operand.
  1117.  
  1118.  
  1119. If either operand is of the component type of an array type, the result  of
  1120. the  catenation is given by the above rules, using in place of this operand
  1121. an array having this operand as its only component  and  having  the  lower
  1122. bound of the index subtype of the array type as its lower bound.
  1123.  
  1124.  
  1125. The  exception  CONSTRAINT_ERROR is raised by catenation if the upper bound
  1126. of the result exceeds the range of the index subtype, unless the result  is
  1127. a  null  array.   This  exception  is  also raised if any operand is of the
  1128. component type but has a value  that  does  not  belong  to  the  component
  1129. subtype.
  1130.  
  1131.  
  1132. Examples:
  1133.  
  1134.     Z + 0.1      --  Z must be of a real type
  1135.  
  1136.     "A" & "BCD"  --  catenation of two string literals
  1137.     'A' & "BCD"  --  catenation of a character literal and a string literal
  1138.     'A' & 'A'    --  catenation of two character literals
  1139.  
  1140.  
  1141. References:   array  type  3.6,  character literal 2.5, component type 3.3,
  1142. constraint_error exception 11.1, dimension 3.6, index subtype  3.6,  length
  1143. of  an array 3.6.2, limited type 7.4.4, null array 3.6.1, numeric type 3.5,
  1144. operation 3.3, operator 4.5, predefined operator 4.5, raising of exceptions
  1145. 11, range of an index subtype 3.6.1, real type 3.5.6, string  literal  2.6,
  1146. type 3.3
  1147.  
  1148. 4.5.4  Unary Adding Operators
  1149.  
  1150.  
  1151. The  unary adding operators + and - are predefined for any numeric type and
  1152. have their conventional meaning.  For each of these operators, the  operand
  1153. and the result have the same type.
  1154.  
  1155.  
  1156.     Operator   Operation   Operand type       Result type
  1157.  
  1158.     +          identity    any numeric type   same numeric type
  1159.  
  1160.     -          negation    any numeric type   same numeric type
  1161.  
  1162.  
  1163. References:   numeric  type  3.5,  operation  3.3, operator 4.5, predefined
  1164. operator 4.5, type 3.3
  1165.  
  1166. 4.5.5  Multiplying Operators
  1167.  
  1168.  
  1169. The operators * and / are predefined for any integer and any floating point
  1170. type and have their conventional meaning;  the operators mod  and  rem  are
  1171. predefined for any integer type.  For each of these operators, the operands
  1172. and  the  result  have  the  same base type.  For floating point types, the
  1173. accuracy of the result is determined by the operand type (see 4.5.7).
  1174.  
  1175.  
  1176.     Operator   Operation           Operand type              Result type
  1177.  
  1178.     *          multiplication      any integer type          same integer type
  1179.                                    any floating point type   same floating point type
  1180.  
  1181.     /          integer division    any integer type          same integer type
  1182.                floating division   any floating point type   same floating point type
  1183.  
  1184.     mod        modulus             any integer type          same integer type
  1185.  
  1186.     rem        remainder           any integer type          same integer type
  1187.  
  1188.  
  1189. Integer division and remainder are defined by the relation
  1190.  
  1191.     A = (A/B)*B + (A rem B)
  1192.  
  1193.  
  1194. where (A rem B) has the sign of A and  an  absolute  value  less  than  the
  1195. absolute value of B.  Integer division satisfies the identity
  1196.  
  1197.     (-A)/B = -(A/B) = A/(-B)
  1198.  
  1199.  
  1200. The  result of the modulus operation is such that (A mod B) has the sign of
  1201. B and an absolute value less than the absolute value of  B;   in  addition,
  1202. for some integer value N, this result must satisfy the relation
  1203.  
  1204.     A = B*N + (A mod B)
  1205.  
  1206.  
  1207. For  each  fixed  point  type,  the  following  multiplication and division
  1208. operators, with an operand of the predefined type INTEGER, are  predefined.
  1209.  
  1210.  
  1211.     Operator   Operation        Left operand type     Right operand type      Result type
  1212.  
  1213.     *          multiplication   any fixed point type  INTEGER                same as left
  1214.                                 INTEGER               any fixed point type   same as right
  1215.  
  1216.     /          division         any fixed point type  INTEGER                same as left
  1217.  
  1218.  
  1219. Integer  multiplication  of  fixed  point  values is equivalent to repeated
  1220. addition.  Division of a fixed point value by an integer does not involve a
  1221. change in type but is approximate (see 4.5.7).
  1222.  
  1223.  
  1224. Finally, the following multiplication and division operators  are  declared
  1225. in  the  predefined package STANDARD.  These two special operators apply to
  1226. operands of all fixed point types (it is a consequence of other rules  that
  1227. they cannot be renamed or given as generic actual parameters).
  1228.  
  1229.  
  1230.     Operator   Operation        Left operand type      Right operand type     Result type
  1231.  
  1232.     *          multiplication   any fixed point type   any fixed point type   universal_fixed
  1233.  
  1234.     /          division         any fixed point type   any fixed point type   universal_fixed
  1235.  
  1236.  
  1237. Multiplication of operands of the same or of different fixed point types is
  1238. exact  and  delivers  a result of the anonymous predefined fixed point type
  1239. universal_fixed whose delta is arbitrarily small.  The result of  any  such
  1240. multiplication  must  always  be explicitly converted to some numeric type.
  1241. This ensures explicit control of the accuracy of the computation.  The same
  1242. considerations apply to division of a fixed point value  by  another  fixed
  1243. point  value.  No other operators are defined for the type universal_fixed.
  1244.  
  1245.  
  1246. The exception NUMERIC_ERROR is raised by integer division, rem, and mod  if
  1247. the right operand is zero.
  1248.  
  1249.  
  1250. Examples:
  1251.  
  1252.     I : INTEGER := 1;
  1253.     J : INTEGER := 2;
  1254.     K : INTEGER := 3;
  1255.  
  1256.     X : REAL digits 6 := 1.0;             --     see 3.5.7
  1257.     Y : REAL digits 6 := 2.0;
  1258.  
  1259.     F : FRACTION delta 0.0001 := 0.1;     --     see 3.5.9
  1260.     G : FRACTION delta 0.0001 := 0.1;
  1261.  
  1262.     Expression        Value     Result Type
  1263.  
  1264.     I*J               2         same as I and J, that is, INTEGER
  1265.     K/J               1         same as K and J, that is, INTEGER
  1266.     K mod J           1         same as K and J, that is, INTEGER
  1267.  
  1268.     X/Y               0.5       same as X and Y, that is, REAL
  1269.     F/2               0.05      same as F, that is, FRACTION
  1270.  
  1271.     3*F               0.3       same as F, that is, FRACTION
  1272.     F*G               0.01      universal_fixed, conversion needed
  1273.     FRACTION(F*G)     0.01      FRACTION, as stated by the conversion
  1274.     REAL(J)*Y         4.0       REAL, the type of both operands after conversion of J
  1275.  
  1276. Notes:
  1277.  
  1278.  
  1279. For positive A and B, A/B is the quotient and A rem B is the remainder when
  1280. A  is  divided  by  B.   The  following  relations are satisfied by the rem
  1281. operator:
  1282.  
  1283.     A    rem (-B) =   A rem B
  1284.     (-A) rem   B  = -(A rem B)
  1285.  
  1286.  
  1287. For any integer K, the following identity holds:
  1288.  
  1289.       A  mod   B  =  (A + K*B) mod B
  1290.  
  1291.  
  1292. The  relations  between  integer  division,  remainder,  and  modulus   are
  1293. illustrated by the following table:
  1294.  
  1295.     A      B   A/B   A rem B  A mod B     A     B    A/B   A rem B   A mod B
  1296.  
  1297.     10     5     2      0         0      -10     5    -2       0           0
  1298.     11     5     2      1         1      -11     5    -2      -1           4
  1299.     12     5     2      2         2      -12     5    -2      -2           3
  1300.     13     5     2      3         3      -13     5    -2      -3           2
  1301.     14     5     2      4         4      -14     5    -2      -4           1
  1302.  
  1303.     10    -5    -2      0         0      -10    -5     2       0         0
  1304.     11    -5    -2      1        -4      -11    -5     2      -1        -1
  1305.     12    -5    -2      2        -3      -12    -5     2      -2        -2
  1306.     13    -5    -2      3        -2      -13    -5     2      -3        -3
  1307.     14    -5    -2      4        -1      -14    -5     2      -4        -4
  1308.  
  1309.  
  1310. References:   actual parameter 6.4.1, base type 3.3, declaration 3.1, delta
  1311. of a fixed point type 3.5.9, fixed point type 3.5.9,  floating  point  type
  1312. 3.5.7,  generic  formal  subprogram  12.1, integer type 3.5.4, numeric type
  1313. 3.5, numeric_error exception 11.1,  predefined  operator  4.5,  raising  of
  1314. exceptions  11,  renaming declaration 8.5, standard predefined package 8.6,
  1315. type conversion 4.6
  1316.  
  1317. 4.5.6  Highest Precedence Operators
  1318.  
  1319.  
  1320. The highest precedence unary operator abs is  predefined  for  any  numeric
  1321. type.   The  highest  precedence  unary  operator not is predefined for any
  1322. boolean type and any one-dimensional array type  whose  components  have  a
  1323. boolean type.
  1324.  
  1325.  
  1326.     Operator   Operation          Operand type                  Result type
  1327.  
  1328.     abs        absolute value     any numeric type              same numeric type
  1329.  
  1330.     not        logical negation   any boolean type              same boolean type
  1331.                                   array of boolean components   same array type
  1332.  
  1333.  
  1334. The  operator  not  that  applies  to  a  one-dimensional  array of boolean
  1335. components yields a one-dimensional boolean array  with  the  same  bounds;
  1336. each  component  of  the  result  is  obtained  by  logical negation of the
  1337. corresponding component of the operand (that is, the component that has the
  1338. same index value).
  1339.  
  1340.  
  1341. The highest precedence exponentiating operator ** is  predefined  for  each
  1342. integer  type  and  for each floating point type.  In either case the right
  1343. operand, called the exponent, is of the predefined type INTEGER.
  1344.  
  1345.  
  1346.     Operator  Operation       Left operand type        Right operand type      Result type
  1347.  
  1348.     **        exponentiation  any integer type         INTEGER                 same as left
  1349.                               any floating point type  INTEGER                 same as left
  1350.  
  1351.  
  1352. Exponentiation  with  a  positive  exponent  is  equivalent   to   repeated
  1353. multiplication  of the left operand by itself, as indicated by the exponent
  1354. and from left to right.  For an operand  of  a  floating  point  type,  the
  1355. exponent  can be negative, in which case the value is the reciprocal of the
  1356. value with the  positive  exponent.   Exponentiation  by  a  zero  exponent
  1357. delivers  the  value  one.   Exponentiation of a value of a floating  point
  1358. type is approximate (see 4.5.7).  Exponentiation of an integer  raises  the
  1359. exception CONSTRAINT_ERROR for a negative exponent.
  1360.  
  1361.  
  1362. References:   array  type 3.6, boolean type 3.5.3, bound of an array 3.6.1,
  1363. component of an array 3.6, constraint_error exception 11.1,  dimensionality
  1364. 3.6,   floating   point   type   3.5.9,  index  3.6,  integer  type  3.5.4,
  1365. multiplication  operation  4.5.5,  predefined  operator  4.5,  raising   of
  1366. exceptions 11
  1367.  
  1368. 4.5.7  Accuracy of Operations with Real Operands
  1369.  
  1370.  
  1371. A  real  subtype  specifies  a  set  of  model  numbers.  Both the accuracy
  1372. required from any basic or predefined operation giving a real  result,  and
  1373. the  result of any predefined relation between real operands are defined in
  1374. terms of these model numbers.
  1375.  
  1376.  
  1377. A model interval of a subtype  is  any  interval  whose  bounds  are  model
  1378. numbers  of  the  subtype.  The model interval associated with a value that
  1379. belongs to a real subtype is the smallest model interval (of  the  subtype)
  1380. that  includes  the  value.   (The  model  interval associated with a model
  1381. number of a subtype consists of that number only.)
  1382.  
  1383.  
  1384. For any basic operation or predefined operator that yields a  result  of  a
  1385. real  subtype,  the  required  bounds  on  the  result are given by a model
  1386. interval defined as follows:
  1387.  
  1388.  
  1389.   -  The result model interval is  the  smallest  model  interval  (of  the
  1390.      result  subtype)  that includes the minimum and the maximum of all the
  1391.      values obtained by applying the (exact) mathematical  operation,  when
  1392.      each  operand is given any value of the model interval (of the operand
  1393.      subtype) defined for the operand.
  1394.  
  1395.  
  1396.   -  The model interval of an operand that  is  itself  the  result  of  an
  1397.      operation,  other  than  an  implicit  conversion, is the result model
  1398.      interval of this operation.
  1399.  
  1400.  
  1401.   -  The model interval of an operand whose value is obtained  by  implicit
  1402.      conversion  of a universal expression is the model interval associated
  1403.      with this value within the operand subtype.
  1404.  
  1405.  
  1406. The result model interval is undefined if the absolute value of one of  the
  1407. above  mathematical  results  exceeds the largest safe number of the result
  1408. type.  Whenever the result  model  interval  is  undefined,  it  is  highly
  1409. desirable  that the exception NUMERIC_ERROR be raised if the implementation
  1410. cannot produce an actual result that is in the range of safe numbers.  This
  1411. is, however, not required by the language rules, in recognition of the fact
  1412. that certain target machines do  not  permit  easy  detection  of  overflow
  1413. situations.  The value of the attribute MACHINE_OVERFLOWS indicates whether
  1414. the   target   machine  raises  the  exception  NUMERIC_ERROR  in  overflow
  1415. situations (see 13.7.3).
  1416.  
  1417.  
  1418. The safe numbers of a real type are defined (see 3.5.6) as  a  superset  of
  1419. the  model  numbers,  for  which  error bounds follow the same rules as for
  1420. model numbers.  Any definition given in this  section  in  terms  of  model
  1421. intervals  can  therefore be extended to safe intervals of safe numbers.  A
  1422. consequence of this extension is that an implementation is not  allowed  to
  1423. raise  the  exception  NUMERIC_ERROR  when  the  result  interval is a safe
  1424. interval.
  1425.  
  1426.  
  1427. For the result of exponentiation, the model interval defining the bounds on
  1428. the result is obtained by applying the  above  rules  to  the  sequence  of
  1429. multiplications  defined  by the exponent, and to the final division in the
  1430. case of a negative exponent.
  1431.  
  1432.  
  1433. For the result of a relation between two real operands, consider  for  each
  1434. operand  the  model  interval  (of  the  operand  subtype)  defined for the
  1435. operand;  the result can be any value obtained by applying the mathematical
  1436. comparison to values arbitrarily chosen in the corresponding operand  model
  1437. intervals.   If  either or both of the operand model intervals is undefined
  1438. (and if neither of the operand evaluations raises an  exception)  then  the
  1439. result  of  the  comparison  is  allowed to be any possible value (that is,
  1440. either TRUE or FALSE).
  1441.  
  1442.  
  1443. The result of a membership test is defined in terms of comparisons  of  the
  1444. operand  value  with  the lower and upper bounds of the given range or type
  1445. mark (the usual rules apply to these comparisons).
  1446.  
  1447. Note:
  1448.  
  1449.  
  1450. For a floating point type the numbers 15.0, 3.0, and 5.0 are  always  model
  1451. numbers.  Hence X/Y where X equals 15.0 and Y equals 3.0 yields exactly 5.0
  1452. according to the above rules.  In the general case, division does not yield
  1453. model numbers and in consequence one cannot assume that (1.0/X)*X = 1.0.
  1454.  
  1455.  
  1456. References:   attribute 4.1.4, basic operation 3.3.3, bound of a range 3.5,
  1457. error bound 3.5.6, exponentiation  operation  4.5.6,  false  boolean  value
  1458. 3.5.3,  floating  point  type  3.5.9,  machine_overflows  attribute 13.7.1,
  1459. membership test 4.5.2, model number 3.5.6, multiplication operation  4.5.5,
  1460. numeric_error  exception  11.1,  predefined  operation  3.3.3,  raising  of
  1461. exceptions 11,  range  3.5,  real  type  3.5.6,  relation  4.4,  relational
  1462. operator  4.5.2  4.5,  safe  number  3.5.6, subtype 3.3, true boolean value
  1463. 3.5.3, type conversion 4.6, type mark 3.3.2, universal expression 4.10
  1464.  
  1465. 4.6  Type Conversions
  1466.  
  1467.  
  1468. The evaluation of an  explicit type  conversion  evaluates  the  expression
  1469. given  as  the  operand,  and  converts  the resulting value to a specified
  1470. target type.  Explicit type conversions are allowed between closely related
  1471. types as defined below.
  1472.  
  1473.  
  1474.     type_conversion ::= type_mark(expression)
  1475.  
  1476.  
  1477. The target type of a type conversion is the base type  of  the  type  mark.
  1478. The  type  of  the  operand  of  a  type  conversion  must  be determinable
  1479. independently of the context (in particular, independently  of  the  target
  1480. type).   Furthermore, the operand of a type conversion is not allowed to be
  1481. a literal null, an allocator,  an  aggregate,  or  a  string  literal;   an
  1482. expression  enclosed  by  parentheses  is  allowed as the operand of a type
  1483. conversion only if the expression alone is allowed.
  1484.  
  1485.  
  1486. A conversion to a subtype consists of  a  conversion  to  the  target  type
  1487. followed  by  a  check  that  the  result  of the conversion belongs to the
  1488. subtype.  A conversion of an operand of a given type to the type itself  is
  1489. allowed.
  1490.  
  1491.  
  1492. The  other  allowed  explicit  type conversions correspond to the following
  1493. three cases:
  1494.  
  1495.  
  1496. (a)  Numeric types
  1497.  
  1498.  
  1499.      The operand can be of any numeric type;  the value of the  operand  is
  1500.      converted  to  the target type which must also be a numeric type.  For
  1501.      conversions involving real types, the result is within the accuracy of
  1502.      the specified subtype (see 4.5.7).  The conversion of a real value  to
  1503.      an  integer  type  rounds  to  the nearest integer;  if the operand is
  1504.      halfway between two integers (within the accuracy of the real subtype)
  1505.      rounding may be either up or down.
  1506.  
  1507.  
  1508. (b)  Derived types
  1509.  
  1510.  
  1511.      The conversion is allowed if one of the target type  and  the  operand
  1512.      type  is  derived  from the other, directly or indirectly, or if there
  1513.      exists a third type from which both types  are  derived,  directly  or
  1514.      indirectly.
  1515.  
  1516.  
  1517. (c)  Array types
  1518.  
  1519.  
  1520.      The  conversion is allowed if the operand type and the target type are
  1521.      array types that satisfy the following conditions:   both  types  must
  1522.      have the same dimensionality;  for each index position the index types
  1523.      must  either  be  the  same  or  be  convertible  to  each other;  the
  1524.      component types must be the same;  finally, if the component type is a
  1525.      type with discriminants or an access type, the component subtypes must
  1526.      be either both constrained or both unconstrained.  If  the  type  mark
  1527.      denotes  an  unconstrained  array type, then, for each index position,
  1528.      the bounds of the result are obtained by converting the bounds of  the
  1529.      operand  to  the  corresponding index type of the target type.  If the
  1530.      type mark denotes a constrained array subtype, then the bounds of  the
  1531.      result  are those imposed by the type mark.  In either case, the value
  1532.      of each component of the result is that of the matching  component  of
  1533.      the operand (see 4.5.2).
  1534.  
  1535.  
  1536. In  the  case  of  conversions  of  numeric  types  and  derived types, the
  1537. exception CONSTRAINT_ERROR is raised by the evaluation of a type conversion
  1538. if the result of the conversion fails to satisfy a  constraint  imposed  by
  1539. the type mark.
  1540.  
  1541.  
  1542. In  the  case  of  array  types, a check is made that any constraint on the
  1543. component subtype is the same for the operand array type as for the  target
  1544. array  type.   If  the type mark denotes an unconstrained array type and if
  1545. the operand is not a null array, then, for each index position, a check  is
  1546. made  that  the  bounds  of  the  result  belong to the corresponding index
  1547. subtype of the target type.  If the type mark denotes a  constrained  array
  1548. subtype,  a check is made that for each component of the operand there is a
  1549. matching component of the target subtype, and vice  versa.   The  exception
  1550. CONSTRAINT_ERROR is raised if any of these checks fails.
  1551.  
  1552.  
  1553. If a conversion is allowed from one type to another, the reverse conversion
  1554. is  also allowed. This reverse conversion is used where an actual parameter
  1555. of mode in out or out has the form of a type  conversion  of  a  (variable)
  1556. name as explained in section 6.4.1.
  1557.                                                                            
  1558.  
  1559. Apart  from  the  explicit  type conversions, the only allowed form of type
  1560. conversion  is  the  implicit  conversion  of   a   value   of   the   type
  1561. universal_integer or universal_real into another numeric type.  An implicit
  1562. conversion of an operand of type universal_integer to another integer type,
  1563. or  of  an operand of type universal_real to another real type, can only be
  1564. applied if the operand is either a numeric literal, a named number,  or  an
  1565. attribute;   such  an  operand is called a convertible universal operand in
  1566. this section.  An implicit conversion of a convertible universal operand is
  1567. applied if and only if the innermost complete context (see 8.7)  determines
  1568. a unique (numeric) target type for the implicit conversion, and there is no
  1569. legal interpretation of this context without this conversion.
  1570.  
  1571. Notes:
  1572.  
  1573.  
  1574. The  rules  for  implicit  conversions imply that no implicit conversion is
  1575. ever applied to the operand of an  explicit  type  conversion.   Similarly,
  1576. implicit  conversions  are  not  applied  if  both operands of a predefined
  1577. relational operator are convertible universal operands.
  1578.  
  1579.  
  1580. The language allows implicit subtype conversions in the case of array types
  1581. (see 5.2.1).  An explicit type conversion can have the effect of  a  change
  1582. of  representation (in particular see 13.6).  Explicit conversions are also
  1583. used for actual parameters (see 6.4).
  1584.  
  1585.  
  1586. Examples of numeric type conversion:
  1587.  
  1588.     REAL(2*J)      --  value is converted to floating point
  1589.     INTEGER(1.6)   --  value is 2
  1590.     INTEGER(-0.4)  --  value is 0
  1591.  
  1592.  
  1593. Example of conversion between derived types:
  1594.  
  1595.     type A_FORM is new B_FORM;
  1596.  
  1597.     X : A_FORM;
  1598.     Y : B_FORM;
  1599.  
  1600.     X := A_FORM(Y);
  1601.     Y := B_FORM(X);  --  the reverse conversion
  1602.  
  1603.  
  1604. Examples of conversions between array types:
  1605.  
  1606.     type SEQUENCE is array (INTEGER range <>) of INTEGER;
  1607.     subtype DOZEN is SEQUENCE(1 .. 12);
  1608.     LEDGER : array(1 .. 100) of INTEGER;
  1609.  
  1610.     SEQUENCE(LEDGER)            --  bounds are those of LEDGER
  1611.     SEQUENCE(LEDGER(31 .. 42))  --  bounds are 31 and 42
  1612.     DOZEN(LEDGER(31 .. 42))     --  bounds are those of DOZEN
  1613.  
  1614.  
  1615. Examples of implicit conversions:
  1616.  
  1617.     X : INTEGER := 2;
  1618.  
  1619.     X + 1 + 2              -- implicit conversion of each integer literal
  1620.     1 + 2 + X              -- implicit conversion of each integer literal
  1621.     X + (1 + 2)            -- implicit conversion of each integer literal
  1622.  
  1623.     2 = (1 + 1)            -- no implicit conversion:  the type is universal_integer
  1624.     A'LENGTH = B'LENGTH    -- no implicit conversion:  the type is universal_integer
  1625.     C : constant := 3 + 2; -- no implicit conversion:  the type is universal_integer
  1626.  
  1627.     X = 3 and 1 = 2        -- implicit conversion of 3, but not of 1 and 2
  1628.  
  1629.  
  1630. References:  actual parameter 6.4.1, array type 3.6, attribute 4.1.4,  base
  1631. type 3.3, belong to a subtype 3.3, component 3.3, constrained array subtype
  1632. 3.6,  constraint_error  exception  11.1,  derived  type 3.4, dimension 3.6,
  1633. expression 4.4, floating point type 3.5.7, index 3.6,  index  subtype  3.6,
  1634. index  type  3.6,  integer  type 3.5.4, matching component 4.5.2, mode 6.1,
  1635. name 4.1, named number 3.2, null array 3.6.1, numeric literal 2.4,  numeric
  1636. type  3.5,  raising of exceptions 11, real type 3.5.6, representation 13.1,
  1637. statement 5, subtype 3.3, type 3.3, type mark  3.3.2,  unconstrained  array
  1638. type 3.6, universal_integer type 3.5.4, universal_real type 3.5.6, variable
  1639. 3.2.1
  1640.  
  1641. 4.7  Qualified Expressions
  1642.  
  1643.  
  1644. A  qualified  expression is used to state explicitly the type, and possibly
  1645. the subtype, of an operand that is the given expression or aggregate.
  1646.  
  1647.  
  1648.     qualified_expression ::=
  1649.        type_mark'(expression) | type_mark'aggregate
  1650.  
  1651.  
  1652. The operand must have the same type as the base type of the type mark.  The
  1653. value of  a  qualified  expression  is  the  value  of  the  operand.   The
  1654. evaluation  of a qualified expression evaluates the operand and checks that
  1655. its value belongs to the subtype denoted by the type mark.   The  exception
  1656. CONSTRAINT_ERROR is raised if this check fails.
  1657.  
  1658.  
  1659. Examples:
  1660.  
  1661.     type MASK is (FIX, DEC, EXP, SIGNIF);
  1662.     type CODE is (FIX, CLA, DEC, TNZ, SUB);
  1663.  
  1664.     PRINT (MASK'(DEC));  --  DEC is of type MASK
  1665.     PRINT (CODE'(DEC));  --  DEC is of type CODE
  1666.  
  1667.     for J in CODE'(FIX) .. CODE'(DEC) loop ... -- qualification needed for either FIX or DEC
  1668.     for J in CODE range FIX .. DEC loop ...    -- qualification unnecessary
  1669.     for J in CODE'(FIX) .. DEC loop ...        -- qualification unnecessary for DEC
  1670.  
  1671.     DOZEN'(1 | 3 | 5 | 7 => 2, others => 0) -- see 4.6
  1672.  
  1673. Notes:
  1674.  
  1675.  
  1676. Whenever  the type of an enumeration literal or aggregate is not known from
  1677. the context,  a  qualified  expression  can  be  used  to  state  the  type
  1678. explicitly.   For  example,  an  overloaded  enumeration  literal  must  be
  1679. qualified in the  following  cases:   when  given  as  a  parameter   in  a
  1680. subprogram  call  to  an  overloaded  subprogram  that  cannot otherwise be
  1681. identified on the basis of  remaining  parameter  or  result  types,  in  a
  1682. relational  expression  where  both  operands  are  overloaded  enumeration
  1683. literals, or in an array or loop parameter  range  where  both  bounds  are
  1684. overloaded  enumeration  literals.   Explicit qualification is also used to
  1685. specify which one of a set of overloaded parameterless functions is  meant,
  1686. or to constrain a value to a given subtype.
  1687.  
  1688.  
  1689. References:  aggregate 4.3, array 3.6, base type 3.3, bound of a range 3.5,
  1690. constraint_error  exception  11.1,  context  of  overload  resolution  8.7,
  1691. enumeration literal 3.5.1, expression 4.4,  function  6.5,  loop  parameter
  1692. 5.5,  overloading  8.5,  raising of exceptions 11, range 3.3, relation 4.4,
  1693. subprogram 6, subprogram call 6.4, subtype 3.3, type 3.3, type mark 3.3.2
  1694.  
  1695. 4.8  Allocators
  1696.  
  1697.  
  1698. The evaluation of an allocator creates an object and yields an access value
  1699. that designates the object.
  1700.  
  1701.  
  1702.     allocator ::=
  1703.        new subtype_indication | new qualified_expression
  1704.  
  1705.  
  1706. The type of the object created by an allocator is the base type of the type
  1707. mark given in either the subtype indication or  the  qualified  expression.
  1708. For  an  allocator with a qualified expression, this expression defines the
  1709. initial value of the created object.  The type of the access value returned
  1710. by an allocator must be determinable solely from the context, but using the
  1711. fact that the value  returned  is  of  an  access  type  having  the  named
  1712. designated type.
  1713.  
  1714.  
  1715. The  only  allowed  forms  of  constraint  in  the subtype indication of an
  1716. allocator are index and discriminant constraints.  If an allocator includes
  1717. a subtype indication and if the type of the object created is an array type
  1718. or a type with discriminants that do not have default expressions, then the
  1719. subtype indication must either denote a constrained subtype, or include  an
  1720. explicit index or discriminant constraint.
  1721.  
  1722.  
  1723. If  the  type  of  the  created  object  is  an  array  type or a type with
  1724. discriminants, then the created  object  is  always  constrained.   If  the
  1725. allocator  includes a subtype indication, the created object is constrained
  1726. either by the subtype or  by  the  default  discriminant  values.   If  the
  1727. allocator   includes   a   qualified  expression,  the  created  object  is
  1728. constrained by the bounds or discriminants of the initial value.  For other
  1729. types, the subtype of the created object is  the  subtype  defined  by  the
  1730. subtype indication of the access type definition.
  1731.  
  1732.  
  1733. For  the  evaluation  of  an  allocator,  the  elaboration  of  the subtype
  1734. indication or the evaluation  of  the  qualified  expression  is  performed
  1735. first.  The new object is then created.  Initializations are then performed
  1736. as  for  a  declared  object (see 3.2.1);  the initialization is considered
  1737. explicit in the case of a qualified expression;   any  initializations  are
  1738. implicit  in  the  case  of a subtype indication.  Finally, an access value
  1739. that designates the created object is returned.
  1740.  
  1741.  
  1742. An implementation must guarantee that any object created by the  evaluation
  1743. of  an allocator remains allocated for as long as this object or one of its
  1744. subcomponents is accessible directly or indirectly, that is, as long as  it
  1745. can  be  denoted  by  some  name.   Moreover,  if  an  object or one of its
  1746. subcomponents belongs to a task type, it is considered to be accessible  as
  1747. long  as  the task is not terminated.  An implementation may (but need not)
  1748. reclaim the storage occupied by an object created  by  an  allocator,  once
  1749. this object has become inaccessible.
  1750.  
  1751.  
  1752. When  an  application  needs  closer  control  over  storage allocation for
  1753. objects designated by values  of  an  access  type,  such  control  may  be
  1754. achieved by one or more of the following means:
  1755.  
  1756.  
  1757. (a)  The total amount of storage available for the collection of objects of
  1758.      an access type can be set by means of a length clause (see 13.2).
  1759.  
  1760.  
  1761. (b)  The  pragma  CONTROLLED  informs  the  implementation  that  automatic
  1762.      storage  reclamation  must  not be performed for objects designated by
  1763.      values of the access type, except upon  leaving  the  innermost  block
  1764.      statement, subprogram body, or task body that encloses the access type
  1765.      declaration, or after leaving the main program.
  1766.  
  1767.         pragma CONTROLLED (access_type_simple_name);
  1768.  
  1769.  
  1770.      A  pragma  CONTROLLED  for  a given access type is allowed at the same
  1771.      places as a representation clause  for  the  type  (see  13.1).   This
  1772.      pragma is not allowed for a derived type.
  1773.  
  1774.  
  1775. (c)  The explicit deallocation of the object designated by an access  value
  1776.      can  be  achieved  by calling a procedure obtained by instantiation of
  1777.      the predefined generic library procedure  UNCHECKED_DEALLOCATION  (see
  1778.      13.10.1).
  1779.  
  1780.  
  1781. The  exception  STORAGE_ERROR  is  raised  by  an allocator if there is not
  1782. enough storage.  Note also  that  the  exception  CONSTRAINT_ERROR  can  be
  1783. raised by the evaluation of the qualified expression, by the elaboration of
  1784. the subtype indication, or by the initialization.
  1785.  
  1786.  
  1787. Examples (for access types declared in section 3.8):
  1788.  
  1789.     new CELL'(0, null, null)                          -- initialized explicitly
  1790.     new CELL'(VALUE => 0, SUCC => null, PRED => null) -- initialized explicitly
  1791.     new CELL                                          -- not initialized
  1792.  
  1793.     new MATRIX(1 .. 10, 1 .. 20)                      -- the bounds only are given
  1794.     new MATRIX'(1 .. 10 => (1 .. 20 => 0.0))          -- initialized explicitly
  1795.  
  1796.     new BUFFER(100)                                   -- the discriminant only is given
  1797.  
  1798.     new BUFFER'(SIZE => 80, POS => 0, VALUE => (1 .. 80 => 'A')) -- initialized explicitly
  1799.  
  1800.  
  1801. References:  access type 3.8, access type definition 3.8, access value 3.8,
  1802. array  type  3.6,  block statement 5.6, bound of an array 3.6.1, collection
  1803. 3.8, constrained subtype 3.3, constraint  3.3,  constraint_error  exception
  1804. 11.1,  context of overload resolution 8.7, derived type 3.4, designate 3.8,
  1805. discriminant  3.3,  discriminant   constraint   3.7.2,   elaboration   3.9,
  1806. evaluation  of  a  qualified  expression 4.7, generic procedure 12.1, index
  1807. constraint 3.6.1, initial value 3.2.1, initialization 3.2.1,  instantiation
  1808. 12.3,  length  clause 13.2, library unit 10.1, main program 10.1, name 4.1,
  1809. object 3.2.1, object declaration 3.2.1, pragma 2.8, procedure 6,  qualified
  1810. expression  4.7,  raising  of  exceptions  11,  representation clause 13.1,
  1811. simple name 4.1, storage_error exception 11.1, subcomponent 3.3, subprogram
  1812. body 6.3, subtype 3.3, subtype indication 3.3.2, task body 9.1,  task  type
  1813. 9.2, terminated task 9.4, type 3.3, type declaration 3.3.1, type mark 3.3.2
  1814. type with discriminants 3.3
  1815.  
  1816. 4.9  Static Expressions and Static Subtypes
  1817.  
  1818.  
  1819. Certain  expressions  of  a  scalar type are said to be static.  Similarly,
  1820. certain discrete ranges are said to  be  static,  and  the  type  marks  of
  1821. certain scalar subtypes are said to denote static subtypes.
  1822.  
  1823.  
  1824. An  expression  of  a scalar type is said to be static if and only if every
  1825. primary is one of those listed in (a) through  (h)  below,  every  operator
  1826. denotes  a  predefined  operator,  and  the  evaluation  of  the expression
  1827. delivers a value (that is, it does not raise an exception):
  1828.  
  1829.  
  1830. (a)  An enumeration literal (including a character literal).
  1831.  
  1832.  
  1833. (b)  A numeric literal.
  1834.  
  1835.  
  1836. (c)  A named number.
  1837.  
  1838.  
  1839. (d)  A constant explicitly declared by a constant declaration with a static
  1840.      subtype, and initialized with a static expression.
  1841.  
  1842.  
  1843. (e)  A function call whose function name is an operator symbol that denotes
  1844.      a predefined operator, including a function name that is  an  expanded
  1845.      name;  each actual parameter must also be a static expression.
  1846.  
  1847.  
  1848. (f)  A language-defined attribute of a static subtype;   for  an  attribute
  1849.      that  is  a  function,  the  actual  parameter  must  also be a static
  1850.      expression.
  1851.  
  1852.  
  1853. (g)  A qualified expression whose type mark denotes a  static  subtype  and
  1854.      whose operand is a static expression.
  1855.  
  1856.  
  1857. (h)  A static expression enclosed in parentheses.
  1858.  
  1859.  
  1860. A  static  range  is a range whose bounds are static expressions.  A static
  1861. range constraint is a range constraint whose range  is  static.   A  static
  1862. subtype is either a scalar base type, other than a generic formal type;  or
  1863. a  scalar  subtype  formed  by imposing on a static subtype either a static
  1864. range constraint, or a floating  or  fixed  point  constraint  whose  range
  1865. constraint,  if any, is static.  A static discrete range is either a static
  1866. subtype or  a  static  range.   A  static  index  constraint  is  an  index
  1867. constraint  for which each index subtype of the corresponding array type is
  1868. static, and in which each discrete range is static.  A static  discriminant
  1869. constraint  is  a  discriminant  constraint  for  which the subtype of each
  1870. discriminant is static, and in which each expression is static.
  1871.  
  1872. Notes:
  1873.  
  1874.  
  1875. The accuracy of the evaluation of a static expression having a real type is
  1876. defined by the rules given in section 4.5.7.  If the result is not a  model
  1877. number  (or  a  safe  number)  of  the  type,  the  value  obtained by this
  1878. evaluation at compilation time need not be the same as the value that would
  1879. be obtained by an evaluation at run time.
  1880.  
  1881.  
  1882. Array attributes are not static:  in particular, the RANGE attribute is not
  1883. static.
  1884.  
  1885.  
  1886. References:  actual parameter 6.4.1, attribute 4.1.4, base type 3.3,  bound
  1887. of a range 3.5, character literal 2.5, constant 3.2.1, constant declaration
  1888. 3.2.1,  discrete  range  3.6, discrete type 3.5, enumeration literal 3.5.1,
  1889. exception 11, expression 4.4, function 6.5, generic actual parameter  12.3,
  1890. generic  formal  type  12.1.2,  implicit declaration 3.1, initialize 3.2.1,
  1891. model number 3.5.6, named  number  3.2,  numeric  literal  2.4,  predefined
  1892. operator  4.5,  qualified  expression  4.7, raising of exceptions 11, range
  1893. constraint 3.5, safe number 3.5.6, scalar type 3.5, subtype 3.3, type  mark
  1894. 3.3.2
  1895.  
  1896. 4.10  Universal Expressions
  1897.  
  1898.  
  1899. A  universal_expression  is  either an expression that delivers a result of
  1900. type  universal_integer  or  one   that   delivers   a   result   of   type
  1901. universal_real.
  1902.  
  1903.  
  1904. The  same  operations  are predefined for the type universal_integer as for
  1905. any integer  type.   The  same  operations  are  predefined  for  the  type
  1906. universal_real  as  for  any  floating  point  type.   In  addition,  these
  1907. operations include the following multiplication and division operators:
  1908.  
  1909.  
  1910.     Operator  Operation       Left operand type  Right operand type  Result type
  1911.  
  1912.     *         multiplication  universal_real     universal_integer   universal_real
  1913.                               universal_integer  universal_real      universal_real
  1914.  
  1915.     /         division        universal_real     universal_integer   universal_real
  1916.  
  1917.  
  1918. The  accuracy  of  the  evaluation  of  a  universal  expression  of   type
  1919. universal_real  is at least as good as that of the most accurate predefined
  1920. floating  point  type  supported  by   the   implementation,   apart   from
  1921. universal_real  itself.  Furthermore, if a universal expression is a static
  1922. expression, then the evaluation must be exact.
  1923.  
  1924.  
  1925. For the evaluation of an operation of a nonstatic universal expression,  an
  1926. implementation  is allowed to raise the exception NUMERIC_ERROR only if the
  1927. result of the operation is a real value whose absolute  value  exceeds  the
  1928. largest  safe  number  of  the most accurate predefined floating point type
  1929. (excluding universal_real), or an integer value greater than SYSTEM.MAX_INT
  1930. or less than SYSTEM.MIN_INT.
  1931.  
  1932. Note:
  1933.  
  1934.  
  1935. It is a consequence of the  above  rules  that  the  type  of  a  universal
  1936. expression   is   universal_integer  if  every  primary  contained  in  the
  1937. expression is of this type (excluding actual parameters of attributes  that
  1938. are  functions,  and  excluding right operands of exponentiation operators)
  1939. and that otherwise the type is universal_real.
  1940.  
  1941.  
  1942. Examples:
  1943.  
  1944.     1 + 1       -- 2
  1945.     abs(-10)*3  -- 30
  1946.  
  1947.     KILO : constant := 1000;
  1948.     MEGA : constant := KILO*KILO;   -- 1_000_000
  1949.     LONG : constant := FLOAT'DIGITS*2;
  1950.  
  1951.     HALF_PI    : constant := PI/2;           -- see 3.2.2
  1952.     DEG_TO_RAD : constant := HALF_PI/90;
  1953.     RAD_TO_DEG : constant := 1.0/DEG_TO_RAD; -- equivalent to 1.0/((3.14159_26536/2)/90)
  1954.  
  1955.  
  1956. References:  actual parameter 6.4.1,  attribute  4.1.4,  evaluation  of  an
  1957. expression  4.5,  floating  point  type  3.5.9,  function 6.5, integer type
  1958. 3.5.4, multiplying operator 4.5 4.5.5, predefined operation 3.3.3,  primary
  1959. 4.4,   real   type   3.5.6,   safe   number   3.5.6,  system.max_int  13.7,
  1960. system.min_int 13.7, type 3.3, universal_integer type 3.5.4, universal_real
  1961. type 3.5.6
  1962.